<%
	
	if (com.zjht.gmcc.bean.util.MySession.getOrgname(session).length() == 0) {
			out.print("<script>window.opener.location.href='/logon.jsp';window.close();</script>");
			return;
			
	}
	String strFileName = request.getParameter("name");
	String suffix=strFileName.substring(strFileName.lastIndexOf(".")+1).toUpperCase();
	String strFile = request.getParameter("file");
	String strFilePath = com.zjht.gmcc.bean.util.MyPath.PATH_BUY;
    if(strFileName == null || strFileName.length()==0) {
    
    	out.print("<script>alert('错误：文件名不能为空！');window.close();';</script>");
		return;
    }
    
    if(strFilePath == null || strFilePath.length()==0) {
    
    	out.print("<script>alert('错误：文件路径不能为空！');window.close();';</script>");
		return;
    }
    
    java.io.FileInputStream fileInputStream=null;
	
	try {
		strFilePath=strFilePath.toUpperCase();
		String strFilePathOK=strFilePath;
		int i=0;
		if(strFilePathOK.length()>0){
			strFile=java.net.URLDecoder.decode(strFile,"ISO8859_1");
			strFile=new String(strFile.getBytes("ISO8859_1"),"GBK");
			String strRealName= strFile+"."+suffix;
			String strFullPath = strFilePathOK +strRealName; 
			//System.out.println(strFullPath+","+strFilePathOK+","+strRealName);
			response.setContentType("application/x-msdownload;");
			response.setHeader("Content-Disposition", "attachment; filename=\""+ new String(strRealName.getBytes("GBK"),"ISO8859-1")+"\"");
			fileInputStream=new java.io.FileInputStream(strFullPath);			        
			while ((i = fileInputStream.read()) != -1) {
				out.write(i);
			}
		}
	} catch(Exception ex) {	
		out.print("文件未找到！");				
		return;
	} finally {
	if(fileInputStream!=null)
	{
		fileInputStream.close(); 
		fileInputStream=null;
	}
}        
%>
